<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>服务-护理培训/培训义工 编辑页面</title>
        <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
        <jsp:include page="../com/header.jsp"></jsp:include>
        <script type="text/javascript" src="../../js/comm/editcomm.js"></script>
        <script type="text/javascript">
		$(function(){
			//getDataById(root + 'cms/nurseTraining/findNurseTrainingById',"#nurseTrainingTmpl","#nurseTrainingContent");
			$("#saveOrupdate").click(function(){
				$("#nurseTraining_url").val(imgUrl);
				if (!$('#nurseTrainingContent').find('#myImageShow').attr('src')) {
					myAlert("请上传图片");
					return;
				}
				saveData(root + 'cms/nurseTraining/saveNurseTraining','nurseTrainingList.jsp');
			});


			var tId = getUrlParam("id");
			if (!tId) {
				myAlert('id参数不能为空');
				return;
			}
			$.ajax({
				url : root + 'cms/nurseTraining/findNurseTrainingById',
				type : 'post',
				dataType : 'json',
				data : {
					modelId : tId
				},
				success : function(data) {
					console.log(data);
					if (data.code == 1) {
						var contentHtml = $('#nurseTrainingTmpl').render(data.object, {
							mydata : data
						});
						$('#nurseTrainingContent').html(contentHtml);
						ue = UE.getEditor("nurseTraining_Content");
						ue.addListener("ready", function() {
							if (data.object.nurseTraining_Content)
								ue.setContent(data.object.nurseTraining_Content);
						});

                        //创建date
                        var d=new Date();
                        //年
                        var year=d.getFullYear();
                        //月
                        var month=d.getMonth()+1;
                        //日
                        var day=d.getDate();
                        var time=year+"-"+month+"-"+day;

						//培训时间
						$("#nurseTraining_StartTime").datetimepicker({minView: "hour",format: 'yyyy-mm-dd hh:ii',language : 'zh-CN',todayBtn:true, todayHighlight:true,autoclose: true,startDate:time}).on('changeDate',function(ev){
		            		var starttime=$("#nurseTraining_StartTime").val();
		            		$("#nurseTraining_EndTime").datetimepicker('setStartDate',starttime);
		            		$("#nurseTraining_StartTime").datetimepicker('hide');
		            	});
						$("#nurseTraining_EndTime").datetimepicker({minView: "hour",format: 'yyyy-mm-dd hh:ii',language : 'zh-CN',todayBtn:true, todayHighlight:true,autoclose: true}).on('changeDate',function(ev){
		            		var endtime=$("#endTime").val();
		            		$("#nurseTraining_StartTime").datetimepicker('setEndDate',endtime);

		            		$("#nurseTraining_EndTime").datetimepicker('hide');
		            	});
						//报名时间
						$("#orderStartTime").datetimepicker({minView: "hour",format: 'yyyy-mm-dd hh:ii',language : 'zh-CN',todayBtn:true, todayHighlight:true,autoclose: true}).on('changeDate',function(ev){
		            		var starttime=$("#orderStartTime").val();
		            		$("#orderEndTime").datetimepicker('setStartDate',starttime);
		            		$("#orderStartTime").datetimepicker('hide');
		            	});
						$("#orderEndTime").datetimepicker({minView: "hour",format: 'yyyy-mm-dd hh:ii',language : 'zh-CN',todayBtn:true, todayHighlight:true,autoclose: true}).on('changeDate',function(ev){
		            		var endtime=$("#endTime").val();
		            		$("#orderStartTime").datetimepicker('setEndDate',endtime);
		            		$("#orderEndTime").datetimepicker('hide');
		            	});

					}else{
						var contentHtml = $('#nurseTrainingTmpl').render("");
						$('#nurseTrainingContent').html(contentHtml);
					}
				}
			});

			//上传图片
			$('#nurseTrainingContent').on('click','#uploadPhotoFile', function () {
				upload("nurseTraining");
	        });
		});
    </script>
    </head>
    <body>
      <section>
          <div>
              <div class="col-xs-12">
                  <div class="box" style="height:900px">
                      <div class="box-header">
                      <br>
                          <input type="button" value="确定" id="saveOrupdate" class="btn btn-success">
                          <input type="button" onclick="backAction('nurseTrainingList.jsp');" class="btn btn-info" value="返回"/>

                      </div>
                     <form id="submit_form" class="form-horizontal">
                        <div class="tab" id="nurseTrainingContent">
                  	    </div>
                  	 </form>
              </div>
          </div>
      </section>
      <script type="text/x-jsrender" id="nurseTrainingTmpl">
			<fieldset> 
				<input type="hidden" id="tId" name="id" value="{{:id}}" />
	        	{{!--<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">图片：</label>
       				 <div class="col-md-3">
						<div class="upload_div">
                        	<img id="myImageShow" src="../../{{:imgUrl}}" width="100px" height="100px" />
                        	<input type="hidden" id="imgUrl" name="imgUrl" value="{{:imgUrl}}"/>
                        	<input type="file" id="uploadPhotoFile" name="photoFile" class="upload_file">
                        </div>
					</div>
      			</div>--}}
				<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">培训岗位：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写培训岗位" class="form-control input-sm" data-rule="required;length[0~50]" id="nurseTraining_Name" name="nurseTraining_Name" value="{{:nurseTraining_Name}}" />
					</div>
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">培训价格：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写培训价格" class="form-control input-sm" data-rule="required;length[0~50];plus;" id="price" name="price" value="{{:price}}" />
					</div>
      			</div>
				
				<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">培训中心的图片：</label>
       				 <div class="col-md-3">
						<div class="upload_div">
						<img id="myImageShow" src="../../{{:nurseTraining_url}}" width="100px" height="100px" />
                        	<input type="hidden" id="nurseTraining_url" name="nurseTraining_url" value="{{:nurseTraining_url}}"/>
                        	<input type="file" id="uploadPhotoFile" name="photoFile" class="upload_file">
						</div>
					</div>
      			</div>


				<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">培训开始时间：</label>
       				 <div class="col-md-3">
       				    <div class="datetime_clear"></div>
						<input type="text" placeholder="请填写培训开始时间" class="form-control input-sm input-group date form_datetime"
						 data-rule="required;length[0~50]"
						id="nurseTraining_StartTime" name="nurseTraining_StartTime" value="{{:nurseTraining_StartTime}}" />
					</div>
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">培训结束时间：</label>
       				 <div class="col-md-3">
       				     <div class="datetime_clear"></div>
						<input type="text" placeholder="请填写培训结束时间"  class="form-control input-sm" data-rule="required;length[0~50]" id="nurseTraining_EndTime" name="nurseTraining_EndTime" value="{{:nurseTraining_EndTime}}" />
					</div>
      			</div>
				<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">培训地址：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写培训地址" class="form-control input-sm" data-rule="required;length[0~255]" id="nurseTraining_Address" name="nurseTraining_Address" value="{{:nurseTraining_Address}}" />
					</div>
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">培训单位：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写培训单位，培训组织" class="form-control input-sm" data-rule="required;length[0~100]" id="nurseTraining_organization" name="nurseTraining_organization" value="{{:nurseTraining_organization}}" />
					</div>
      			</div>
				<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">培训总名额：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写培训总名额" class="form-control input-sm" data-rule="required;length[0~50]" id="quantity" name="quantity" value="{{:quantity}}" />
					</div>
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">培训名额库存：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写培训名额库存" class="form-control input-sm" data-rule="required;length[0~50]" id="quantityInventory" name="quantityInventory" value="{{:quantityInventory}}" />
					</div>
      			</div>
				<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">报名开始时间：</label>
       				 <div class="col-md-3">
       				     <div class="datetime_clear"></div>
						<input type="text" placeholder="请填写报名开始时间"  class="form-control input-sm" data-rule="length[0~50];required;" id="orderStartTime" name="orderStartTime" value="{{:orderStartTime}}" />
					</div>
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">报名结束时间：</label>
       				 <div class="col-md-3">
       				     <div class="datetime_clear"></div>
						<input type="text" placeholder="请填写报名结束时间"   class="form-control input-sm" data-rule="length[0~50];required" id="orderEndTime" name="orderEndTime" value="{{:orderEndTime}}" />
					</div>
      			</div>
      			<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">客服电话：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写客服电话" class="form-control input-sm" data-rule="required;length[0~50];" id="mobile" name="mobile" value="{{:mobile}}" />
					</div>
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">排序值：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写排序值" class="form-control input-sm" data-rule="length[1~10];plus" maxlength="10" id="sort" name="sort" value="{{:sort}}" />
					</div>
      			</div>
				<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">图文详情：</label>
       				 <div class="col-md-3">
						<div  id="nurseTraining_Content" name="nurseTraining_Content" style="height:200px;width:760px"></div>
					</div>
      			</div>
				
			</fieldset>
	</script>
    </body>
</html>